package org.seedltd.upms.service.impl.sys;

import org.seedltd.core.base.BaseParseUserService;
import org.seedltd.core.model.UserEnumVO;
import org.seedltd.upms.model.sys.entity.SysUser;
import org.seedltd.upms.service.sys.SysUserService;
import org.springframework.stereotype.Service;

/**
 * @author laizuan
 * @since 2019年12月23日 11:44
 */
@Service
public class BaseParseUserServiceImpl extends BaseParseUserService {

    private final SysUserService sysUserService;

    public BaseParseUserServiceImpl(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    @Override
    public UserEnumVO getUserById(Long id) {
        if (id == null) {
            return null;
        }
        SysUser sysUser = sysUserService.findById(id);
        if (sysUser == null) {
            return null;
        }
        return new UserEnumVO(sysUser.getUserId(), sysUser.getNickName());
    }
}
